/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vamprest;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author sav
 */
@Entity
@Table(name = "constructor")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Constructor.findAll", query = "SELECT c FROM Constructor c"),
    @NamedQuery(name = "Constructor.findByIdconstructor", query = "SELECT c FROM Constructor c WHERE c.idconstructor = :idconstructor")})
public class Constructor implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "idconstructor")
    private Integer idconstructor;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "name")
    private String name;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idconstructor")
    private Collection<Vehicle> vehicleCollection;

    public Constructor() {
    }

    public Constructor(Integer idconstructor) {
        this.idconstructor = idconstructor;
    }

    public Constructor(Integer idconstructor, String name) {
        this.idconstructor = idconstructor;
        this.name = name;
    }

    public Integer getIdconstructor() {
        return idconstructor;
    }

    public void setIdconstructor(Integer idconstructor) {
        this.idconstructor = idconstructor;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    public Collection<Vehicle> getVehicleCollection() {
        return vehicleCollection;
    }

    public void setVehicleCollection(Collection<Vehicle> vehicleCollection) {
        this.vehicleCollection = vehicleCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idconstructor != null ? idconstructor.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Constructor)) {
            return false;
        }
        Constructor other = (Constructor) object;
        if ((this.idconstructor == null && other.idconstructor != null) || (this.idconstructor != null && !this.idconstructor.equals(other.idconstructor))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "vamprest.Constructor[ idconstructor=" + idconstructor + " ]";
    }

}
